<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="support.*,java.util.*,java.sql.*,javax.sql.*"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Name Page</title>

<script type="text/javascript">
function validate() {
	var first = document.getElementById("first").value;
	var middle = document.getElementById("middle").value;
	var last = document.getElementById("last").value;
	var submitOK = "true";
	var error = "";

	if (first.length == 0 || last.length == 0)
	{
		submitOK = "false";
		error = "empty"
	}

	else {
			var alphaExp = /^[a-zA-Z]+$/;
			if (!first.match(alphaExp)) {
				submitOK = "false";
				error = "letter"
			}

			if (middle.length != 0 && !middle.match(alphaExp)) {
				submitOK = "false";
				error = "letter"
			}

			if (!last.match(alphaExp)) {
				submitOK = "false";
				error = "letter"
			}
		}

		if (submitOK == "false") {
			if (error == "empty")
			{
				alert("First and last names can not be empty!");
			}
			else
			{
				alert("Entered names are not valid!");
			}
			return false;
		}
	}
</script>
</head>
<body>

	<form method="get" action="login/students/countryOfCitizenship.jsp" onsubmit="return validate()">
		Please enter your name.
		<p>
		<table border="1">
			<tr>
				<td>First Name:</td>
				<td><input id="first" type="text" size="20" name="FirstName" /></td>
			</tr>
			<tr>
				<td>Middle Initial:</td>
				<td><input id="middle" type="text" size="20" name="MiddleI" /></td>
			</tr>
			<tr>
				<td>Last Name:</td>
				<td><input id="last" type="text" size="20" name="LastName" /></td>
			</tr>
			<tr>
				<td colspan="2" align="right"><input type="submit"
					value="submit" size="10" /></td>
			</tr>
		</table>
	</form>
	<%
		java.text.DateFormat df = new java.text.SimpleDateFormat(
				"dd/MM/yyyy");
	%>

	<p>
		Current Date:
		<%=df.format(new java.util.Date())%>
	<p>
		<html:form action="/Logoff">
			<html:submit value="Logoff" />
		</html:form>
</body>
</html>